<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/SearchResultsPage">
    <head>
        <link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
        <link rel="publisher" href="http://google.com/+RentpadPhi" />        
        <title>Apartments, Condos, Houses and Rooms For Rent in ${model.city.title}</title>  
        
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">   
        <meta name="description" content="Search for an apartment, condo, house or a room for rent in ${model.city.title}." />        
        <meta name="keywords" content="apartment for rent in ${model.city.title}, ${model.city.title} apartment for rent, condo for rent in ${model.city.title}, ${model.city.title} condo for rent, condominium for rent in ${model.city.title}, ${model.city.title} condominium for rent, house for rent in ${model.city.title}, ${model.city.title} house for rent, room for rent in ${model.city.title}, ${model.city.title} room for rent"/>
        
        <meta property="og:type" content="website"  />
        <meta property="og:url" content="${model.props.appPath}/long-term-rentals/${model.city.title}"  />
        <meta property="og:title" content="Apartments, Condos, Houses and Rooms For Rent in ${model.city.title} | Rentpad.com.ph"  />
        <meta property="og:description" content="Search for an apartment, condo, house or a room for rent in ${model.city.title}" />
        <meta property="og:image" content="${model.props.appPath}/img/rentpad-logo-1.png"  />
        
        <meta name="twitter:card" content="summary"/>
        <meta name="twitter:site" value="@rentpadph"/>
        <meta name="twitter:url" content="http://rentpad.com.ph"/>
        <meta name="twitter:title" content="Apartments, Condos, Houses and Rooms For Rent in ${model.city.title} | Rentpad.com.ph"/>
        <meta name="twitter:description" content="Search for an apartment, condo, house or a room for rent in ${model.city.title}"/>
        <meta name="twitter:image" content="${model.props.appPath}/img/rentpad-logo-1.png"/>
        
        <meta itemprop="name" content="Apartments, Condos, Houses and Rooms For Rent in ${model.city.title} | Rentpad.com.ph"/>
        <meta itemprop="description" content="Search for an apartment, condo, house or a room for rent in ${model.city.title}."/>
        <meta itemprop="keywords" content="apartment for rent in ${model.city.title}, ${model.city.title} apartment for rent, condo for rent in ${model.city.title}, ${model.city.title} condo for rent, condominium for rent in ${model.city.title}, ${model.city.title} condominium for rent, house for rent in ${model.city.title}, ${model.city.title} house for rent, room for rent in ${model.city.title}, ${model.city.title} room for rent" />
        <meta itemprop="image" content="${model.props.appPath}/img/rentpad-logo-1.png"/>
        
        <link rel="stylesheet" href="https://developers.google.com/maps/documentation/javascript/examples/default.css" />
        <link rel="stylesheet" href="${model.props.appPath}/css/main/listings.css" />                 
	<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />        
        <link rel="stylesheet" href="https://developers.google.com/maps/documentation/javascript/examples/default.css" />
              
        <style>
            @font-face
            {
            font-family: avant;
            src: url('${model.props.appPath}/fonts/avangmi-webfont.ttf');
            }
            -webkit-overflow-scrolling: touch; 
        </style>
        
        <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>        
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>       
        <script type="text/javascript" src="${model.props.appPath}/js/block/jquery.blockUI.js"></script>
        <script type="text/javascript" src="${model.props.appPath}/js/google/analytics.js"></script>
        
        <%@ include file="include/listingsGeoMaps.jsp" %>
        
        <script type="text/javascript">
            var currentView = 1;
                        
            $( document ).ready(function() {
                if (!checkDefaultFilters()) {                                          
                    check();                       
                }
            });
            
            function checkDefaultFilters() {
                var setDefault = true;
                
                var selectedTypes = new Array();                
                $.each($("input[name='typecbx']:checked"), function() {
                    selectedTypes.push($(this).val());
                });                
                              
                var selectedFurnishing = new Array();   
                $.each($("input[name='furnishcbx']:checked"), function() {
                    selectedFurnishing.push($(this).val());
                });                
                
                var longMonthRateLow = $( "#longMonthRateLow" ).val();
                var longMonthRateHigh = $( "#longMonthRateHigh" ).val();
                                
                var numBedroomsLow = $( "#numBedroomsLow" ).val();
                var numBedroomsHigh = $( "#numBedroomsHigh" ).val();
                        
                var sqAreaLow = $( "#sqAreaLow" ).val();
                var sqAreaHigh = $( "#sqAreaHigh" ).val();
                
                var pageNumber = $("#text-page-number").val();
                                
                if (selectedTypes.length > 0) {
                    setDefault = false;
                } 
                
                if (selectedFurnishing.length > 0) {
                    setDefault = false;
                } 
                
                if (longMonthRateLow != 0 || longMonthRateHigh != 999999) {   
                    setDefault = false;
                }
                
                if (numBedroomsLow != 0 || numBedroomsHigh != 999) {                    
                    setDefault = false;
                }
                                                
                if (pageNumber != 1) {
                    setDefault = false; 
                }
                
                return setDefault;
            }
            
            function load() {
                /*
                try {
                    $("#checkbox-propertyType-1").on("click",function() {
                        if (currentView == 3) {
                            resetPaging();
                            markers = [];
                            checkGeo();                              
                        }
                        else {
                            resetPaging();  
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                
                try {
                    $("#checkbox-propertyType-2").on("click",function() {
                        if (currentView == 3) {
                            resetPaging();   
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                
                try {
                    $("#checkbox-propertyType-3").on("click",function() {
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                
                try {
                    $("#checkbox-propertyType-4").on("click",function() {
                        if (currentView == 3) {
                            resetPaging(); 
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                
                try {
                    $("#checkbox-propertyType-5").on("click",function() {
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                                
                try {
                    $("#checkbox-furnishType-3").on("click",function() {
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }

                try {
                    $("#checkbox-furnishType-2").on("click",function() {
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                
                try {
                    $("#checkbox-furnishType-1").on("click",function() {
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                
                try {       
                    $("#select-longMonthRateLow").on("change",function() {
                        $("#longMonthRateLow").val($(this).val());
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                                
                try {       
                    $("#select-longMonthRateHigh").on("change",function() {
                        $("#longMonthRateHigh").val($(this).val());
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                
                
                try {       
                    $("#select-sqAreaLow").on("change",function() {
                        $("#sqAreaLow").val($(this).val());
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                
                
                try {       
                    $("#select-sqAreaHigh").on("change",function() {
                        $("#sqAreaHigh").val($(this).val());
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                                
                try {       
                    $("#select-numBedroomsLow").on("change",function() {
                        $("#numBedroomsLow").val($(this).val());
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                                    
                try {       
                    $("#select-numBedroomsHigh").on("change",function() {
                        $("#numBedroomsHigh").val($(this).val());
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                
                try {       
                    $("#select-numBathroomsLow").on("change",function() {
                        $("#numBathroomsLow").val($(this).val());
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                                    
                try {       
                    $("#select-numBathroomsHigh").on("change",function() {
                        $("#numBathroomsHigh").val($(this).val());
                        if (currentView == 3) {
                            resetPaging();  
                            markers = [];
                            checkGeo();                         
                        }
                        else {
                            resetPaging();
                            check();
                            checkGeo();    
                        }
                     });
                } catch (e) {
                    alert(e);
                }
                */
               
                $.each($("input[name='placeID']"), function() {
                    $("#place-"+$(this).val()).prop( "checked", true );
                });
                $.each($("input[name='propertyTypeID']"), function() {
                    $("#propertyType-"+$(this).val()).prop( "checked", true );
                });         
                
                //CX: initialize maps
                initialize('${model.city.lat}', '${model.city.lng}');                
                checkGeo();   
                
                //CX: search
                //check();
                
                try {
                    var v = ${model.view};
                    if (v == 3) {
                        switchView(3);
                    }                    
                } catch (e) { alert(e); }
            }
                        
            function doSearch() {
                try {
                    $("#longMonthRateLow").val($("#select-longMonthRateLow").val());
                    $("#longMonthRateHigh").val($("#select-longMonthRateHigh").val());
                    $("#sqAreaLow").val($("#select-sqAreaLow").val());
                    $("#sqAreaHigh").val($("#select-sqAreaHigh").val());
                    $("#numBedroomsLow").val($("#select-numBedroomsLow").val());
                    $("#numBedroomsHigh").val($("#select-numBedroomsHigh").val());
                    $("#numBathroomsLow").val($("#select-numBathroomsLow").val());
                    $("#numBathroomsHigh").val($("#select-numBathroomsHigh").val());

                    if (currentView == 3) {
                        resetPaging();
                        markers = [];
                        checkGeo();                              
                    }
                    else {
                        resetPaging();  
                        check();
                        checkGeo(); 
                    }
                } catch (e) { alert("doSearch: " + e); }
            }            
                        
            function resetPaging() {
                $("#text-items-per-page").val("12");
                $("#text-page-number").val("1");                
            }            
                        
            function prev() {                
                var pageNumber = $("#text-page-number").val();
                pageNumber--;
                
                $("#text-page-number").val(pageNumber);
                check();
                
                $('html, body').animate({
                    scrollTop: $("#span-listings-count").offset().top
                }, 500);
            }
            
            function next() {
                var pageNumber = $("#text-page-number").val();
                pageNumber++;
                
                $("#text-page-number").val(pageNumber);   
                check();    
                
                $('html, body').animate({
                    scrollTop: $("#span-listings-count").offset().top
                }, 500);
            }
            
            function check() {
                var cityName = $("#cityName").val();
                
                var selectedTypes = new Array();
                var selectedFurnishing = new Array();
                var selectedPlaces = new Array();
                var selectedStatus = new Array();
                var selectedAmenities = new Array();
                
                $.each($("input[name='typecbx']:checked"), function() {
                    selectedTypes.push($(this).val());
                });                
                $.each($("input[name='furnishcbx']:checked"), function() {
                    selectedFurnishing.push($(this).val());
                });
                $.each($("input[name='placecbx']:checked"), function() {
                    selectedPlaces.push($(this).val());
                });
                $.each($("input[name='statuscbx']:checked"), function() {
                    selectedStatus.push($(this).val());
                });
                $.each($("input[name='amenitycbx']:checked"), function() {
                    selectedAmenities.push($(this).val());
                });
                
                var longMonthRateLow = $( "#longMonthRateLow" ).val();
                var longMonthRateHigh = $( "#longMonthRateHigh" ).val();
                
                var sqAreaLow = $( "#sqAreaLow" ).val();
                var sqAreaHigh = $( "#sqAreaHigh" ).val();
                
                var numBedroomsLow = $( "#numBedroomsLow" ).val();
                var numBedroomsHigh = $( "#numBedroomsHigh" ).val();
                
                var numBathroomsLow = $( "#numBathroomsLow" ).val();
                var numBathroomsHigh = $( "#numBathroomsHigh" ).val();
                        
                var itemsPerPage = $("#text-items-per-page").val();
                var pageNumber = $("#text-page-number").val();
                    
                search(cityName, longMonthRateLow, longMonthRateHigh, sqAreaLow, sqAreaHigh, numBedroomsLow, numBedroomsHigh, numBathroomsLow, numBathroomsHigh, selectedTypes, selectedFurnishing, selectedPlaces, selectedStatus, selectedAmenities, itemsPerPage, pageNumber);   
            }                   
            
            function search(cityName, longMonthRateLow, longMonthRateHigh, sqAreaLow, sqAreaHigh, numBedroomsLow, numBedroomsHigh, numBathroomsLow, numBathroomsHigh, selectedTypes, selectedFurnishing, selectedPlaces, selectedStatus, selectedAmenities, itemsPerPage, pageNumber) {
                try {
                    
                    $.blockUI({ message: "<div style='font-family: avant, Century Gothic, Calibri, Verdana; padding: 10px;'>Loading Properties ...</div>" });
                    
                    $.ajax({
                        type: 'POST',
                        url: "${model.props.appPath}/ws/search.htm",
                        data: {
                            a: 31,
                            cityName: cityName,
                            propertyTypeIDs: "["+selectedTypes+"]",
                            furnishTypeIDs: "["+selectedFurnishing+"]",
                            placeIDs: "["+selectedPlaces+"]",
                            statusTypeIDs: "["+selectedStatus+"]",
                            amenityIDs: "["+selectedAmenities+"]",
                            sqAreaLow: sqAreaLow,
                            sqAreaHigh: sqAreaHigh,
                            longMonthRateLow: longMonthRateLow,
                            longMonthRateHigh: longMonthRateHigh,
                            numBedroomsLow: numBedroomsLow,
                            numBedroomsHigh: numBedroomsHigh,
                            numBathroomsLow: numBathroomsLow,
                            numBathroomsHigh: numBathroomsHigh,
                            itemsPerPage: itemsPerPage,
                            pageNumber: pageNumber,
                            ham: "ham"
                        },
                        timeout : 200000,
                        success: function(data) {
                            try {
                                var host = data.model.host;
                                var port = data.model.port;
                                var rootPath = data.model.props.rootPath;
                                var appPath = data.model.props.appPath;
                                
                                var searchResult = data.model.searchResult;
                                var listings = searchResult.listings;                                
                                var totalListings = searchResult.totalListings;
                                var hasPrev = searchResult.hasPrev;
                                var hasNext = searchResult.hasNext;
                                var featureds = data.model.featureds;
                                
                                //CX: display total count
                                $("#span-listings-count").html(totalListings);
                                
                                //CX: enable / disable prev button                                
                                if (hasPrev) { 
                                    $("#btn-page-prev").removeAttr("disabled");                                 
                                }
                                else {                     
                                    $("#btn-page-prev").attr("disabled", true);                
                                }
                                
                                //CX: enable / disable next button
                                if (hasNext) {
                                    $("#btn-page-next").removeAttr("disabled");                                   
                                }
                                else {
                                    $("#btn-page-next").attr("disabled", true);                                       
                                }
                                
                                //CX: reflect tile view
                                $("#view-tile-float-wrap").empty();  
                                                                
                                for (var i = 0; i < featureds.length; i++) {
                                    var listing = featureds[i];
                                    var prmaryPhoto="";
                                    if (listing.primaryPhoto) {
                                        prmaryPhoto = rootPath+"/uploads/img/002-"+listing.primaryPhoto.filename;
                                    }
                                    else {
                                        prmaryPhoto = appPath+"/img/no-photo.png";
                                    }
                                    
                                    //alert('prmaryPhoto- ' + prmaryPhoto);
                                    
                                    var titleDisplay = listing.title;
                                    if (!listing.available) {
                                        titleDisplay = "<strike>"+listing.title+"</strike>"
                                    }
                                    
                                    var sqmDisplay = "<span style=\"font-size: 13px; \">&nbsp;" + listing.sqArea + "</span><span style=\"font-size: 12px;\"> sqm.</span>"
                                    if (listing.sqArea == "0.0") {
                                        sqmDisplay = "";
                                    }
                                                                        
                                    var listingTitle = listing.urlTitle;
                                                                        
                                    $("#view-tile-float-wrap")
                                            .append("<div class=\"view-tile-left-floater listing-holder\" style=\"min-height: 230px; width: 297px; border: 3px solid rgba(131,201,12,0.5); position: relative; left:-2px;\">\n\
                                                        <a href=\""+appPath+"/long-term-rentals/${fn:toLowerCase(model.city.title)}/"+listingTitle+"/"+listing.id+"\" title=\"Featured Property &#10004;\">\n\
                                                            <div class=\"listing-photo-holder\" style=\"height:147px; width:297px; background: url('"+prmaryPhoto+"'); background-size: 100%; background-repeat:no-repeat;\"></div>\n\
                                                        </a>\n\
                                                            <table border=\"0\" style=\"width: 297px; padding-top:0px; font-family: avant, Century Gothic, Calibri; padding:5px; \">\n\
                                                                <tr>\n\
                                                                    <td colspan=\"2\" style=\"height: 40px; vertical-align: top;\"><div style=\"min-height: 30px; max-height: 30px; font-size: 12px; font-weight: normal; overflow: hidden; overflow-y: hidden; border: 0px solid black;\">"+titleDisplay+"<br></div></td>\n\
                                                                </tr>\n\
                                                                <tr>\n\
                                                                    <td width='106px'>"+sqmDisplay+"</td>\n\
                                                                    <td align=\"right\" style=\"font-weight: bold;\"><span style=\"font-size: 13px; \">&#8369;"+listing.longMonthRate+"</span><span style=\"font-size: 12px;\"> /mo.&nbsp;</span></td>\n\
                                                                </tr>\n\
                                                            </table>\n\
                                                        </div>");
                                }     
                                
                                for (var i = 0; i < listings.length; i++) {
                                    var listing = listings[i];
                                    var prmaryPhoto="";
                                    if (listing.primaryPhoto) {
                                        prmaryPhoto = rootPath+"/uploads/img/002-"+listing.primaryPhoto.filename;
                                    }
                                    else {
                                        prmaryPhoto = appPath+"/img/no-photo.png";
                                    }
                                    
                                    //alert('prmaryPhoto- ' + prmaryPhoto);
                                    
                                    var titleDisplay = listing.title;
                                    if (!listing.available) {
                                        titleDisplay = "<strike>"+listing.title+"</strike>"
                                    }
                                    
                                    var sqmDisplay = "<span style=\"font-size: 13px; \">&nbsp;" + listing.sqArea + "</span><span style=\"font-size: 12px;\"> sqm.</span>"
                                    if (listing.sqArea == "0.0") {
                                        sqmDisplay = "";
                                    }
                                                                        
                                    var listingTitle = listing.urlTitle;
                                                                        
                                    $("#view-tile-float-wrap")
                                            .append("<div class=\"view-tile-left-floater listing-holder\">\n\
                                                        <a href=\""+appPath+"/long-term-rentals/${fn:toLowerCase(model.city.title)}/"+listingTitle+"/"+listing.id+"\">\n\
                                                            <div class=\"listing-photo-holder\" style=\"height:150px; width:300px; background: url('"+prmaryPhoto+"'); background-size: 100%; background-repeat:no-repeat;\"></div>\n\
                                                        </a>\n\
                                                            <table border=\"0\" style=\"width: 300px; padding-top:0px; font-family: avant, Century Gothic, Calibri; padding:5px; \">\n\
                                                                <tr>\n\
                                                                    <td colspan=\"2\" style=\"height: 40px; vertical-align: top;\"><div style=\"min-height: 30px; max-height: 30px; font-size: 12px; font-weight: normal; overflow: hidden; overflow-y: hidden; border: 0px solid black;\">"+titleDisplay+"<br></div></td>\n\
                                                                </tr>\n\
                                                                <tr>\n\
                                                                    <td width='106px'>"+sqmDisplay+"</td>\n\
                                                                    <td align=\"right\" style=\"font-weight: bold;\"><span style=\"font-size: 13px; \">&#8369;"+listing.longMonthRate+"</span><span style=\"font-size: 12px;\"> /mo.&nbsp;</span></td>\n\
                                                                </tr>\n\
                                                            </table>\n\
                                                        </div>");
                                }                      
                                
                                //CX: reflect list view                                                 
                                $("#view-list-outer").empty();  
                                                                
                                for (var i = 0; i < featureds.length; i++) {
                                    var listing = featureds[i];      
                                    
                                    var prmaryPhoto="";
                                    if (listing.primaryPhoto) {
                                        prmaryPhoto = rootPath+"/uploads/img/002-"+listing.primaryPhoto.filename;
                                    }
                                    else {
                                        prmaryPhoto = appPath+"/img/no-photo.png";
                                    }
                                    
                                    var titleDisplay = listing.title;
                                    if (!listing.available) {
                                        titleDisplay = "<strike>"+listing.title+"</strike>"
                                    }
                                    
                                    var sqmDisplay = "<span style=\"font-size: 16px; font-weight: normal;\">" + listing.sqArea + "</span><span style=\"font-size: 12px;\"> sqm.</span>";
                                    if (listing.sqArea == "0.0") {
                                        sqmDisplay = "";
                                    }
                                                                        
                                    var listingTitle = listing.urlTitle;
                                    $("#view-list-outer")
                                            .append("<div class=\"list-listing-holder\" style=\"background-color:#f8f8f8; width: 97%; margin-top: 10px; margin-left:10px; font-family: avant, Century Gothic, Calibri; border: 3px solid rgba(131,201,12,0.5);\" title=\"Featured Property &#10004;\">\n\
                                                                    <table cellpadding=\"3\" style=\"width:100%; font-family: avant, Century Gothic, Calibri;\">\n\
                                                                        <tr>\n\
                                                                            <td style=\"height: 100px; width: 10%\">\n\
                                                                                <a href=\""+appPath+"/long-term-rentals/${fn:toLowerCase(model.city.title)}/"+listingTitle+"/"+listing.id+"\">\n\
                                                                                    <div class=\"list-listing-holder\" style=\"height:110px; width:200px; background: url('"+prmaryPhoto+"'); background-size:cover; \"></div>\n\
                                                                                </a>\n\
                                                                            </td>\n\
                                                                            <td style=\"vertical-align: top;\">\n\
                                                                                <table border=\"0\" style=\"width: 98%; padding-top:15px; margin-left: 0px;\">\n\
                                                                                    <tr>\n\
                                                                                        <td style=\"vertical-align: top;  width: 550px;\">\n\
                                                                                            <div style=\"padding-top:5px; padding-bottom:0px;\">\n\
                                                                                                <span style=\"font-size: 16px; font-family: avant, Century Gothic, Calibri; padding-bottom: 10px; font-weight: normal;\">"+titleDisplay+"</span>\n\
                                                                                            </div>\n\
                                                                                            <div style=\"padding-top:8px; padding-bottom:0px;\"><span style=\"font-size: 14px; font-weight: normal;\">"+listing.address+"</span></div>\n\
                                                                                        </td>\n\
                                                                                        <td style=\"vertical-align: top;\" align=\"right\" style=\"width: 222px\">\n\
                                                                                            <span style=\"font-size: 22px; font-weight: normal;\">&#8369; "+listing.longMonthRate+"</span>\n\
                                                                                            <span style=\"font-size: 12px;\"> /Mo.</span></div>\n\
                                                                                            <div style=\"padding-top:5px; padding-bottom:0px;\">"+sqmDisplay+"</div>\n\
                                                                                        </td>\n\
                                                                                    </tr>\n\
                                                                                </table>\n\
                                                                            </td>\n\
                                                                        </tr>\n\
                                                                    </table>\n\
                                                                 </div>");
                                }
                                
                                for (var i = 0; i < listings.length; i++) {
                                    var listing = listings[i];      
                                    
                                    var prmaryPhoto="";
                                    if (listing.primaryPhoto) {
                                        prmaryPhoto = rootPath+"/uploads/img/002-"+listing.primaryPhoto.filename;
                                    }
                                    else {
                                        prmaryPhoto = appPath+"/img/no-photo.png";
                                    }
                                    
                                    var titleDisplay = listing.title;
                                    if (!listing.available) {
                                        titleDisplay = "<strike>"+listing.title+"</strike>"
                                    }
                                    
                                    var sqmDisplay = "<span style=\"font-size: 16px; font-weight: normal;\">" + listing.sqArea + "</span><span style=\"font-size: 12px;\"> sqm.</span>";
                                    if (listing.sqArea == "0.0") {
                                        sqmDisplay = "";
                                    }
                                                                        
                                    var listingTitle = listing.urlTitle;
                                    $("#view-list-outer")
                                            .append("<div class=\"list-listing-holder\" style=\"background-color:#f8f8f8; width: 97%; margin-top: 10px; margin-left:10px; font-family: avant, Century Gothic, Calibri;\">\n\
                                                                    <table cellpadding=\"3\" style=\"width:100%; font-family: avant, Century Gothic, Calibri;\">\n\
                                                                        <tr>\n\
                                                                            <td style=\"height: 100px; width: 10%\">\n\
                                                                                <a href=\""+appPath+"/long-term-rentals/${fn:toLowerCase(model.city.title)}/"+listingTitle+"/"+listing.id+"\">\n\
                                                                                    <div class=\"list-listing-holder\" style=\"height:110px; width:200px; background: url('"+prmaryPhoto+"'); background-size:cover; \"></div>\n\
                                                                                </a>\n\
                                                                            </td>\n\
                                                                            <td style=\"vertical-align: top;\">\n\
                                                                                <table border=\"0\" style=\"width: 98%; padding-top:15px; margin-left: 0px;\">\n\
                                                                                    <tr>\n\
                                                                                        <td style=\"vertical-align: top;  width: 550px;\">\n\
                                                                                            <div style=\"padding-top:5px; padding-bottom:0px;\">\n\
                                                                                                <span style=\"font-size: 16px; font-family: avant, Century Gothic, Calibri; padding-bottom: 10px; font-weight: normal;\">"+titleDisplay+"</span>\n\
                                                                                            </div>\n\
                                                                                            <div style=\"padding-top:8px; padding-bottom:0px;\"><span style=\"font-size: 14px; font-weight: normal;\">"+listing.address+"</span></div>\n\
                                                                                        </td>\n\
                                                                                        <td style=\"vertical-align: top;\" align=\"right\" style=\"width: 222px\">\n\
                                                                                            <span style=\"font-size: 22px; font-weight: normal;\">&#8369; "+listing.longMonthRate+"</span>\n\
                                                                                            <span style=\"font-size: 12px;\"> /Mo.</span></div>\n\
                                                                                            <div style=\"padding-top:5px; padding-bottom:0px;\">"+sqmDisplay+"</div>\n\
                                                                                        </td>\n\
                                                                                    </tr>\n\
                                                                                </table>\n\
                                                                            </td>\n\
                                                                        </tr>\n\
                                                                    </table>\n\
                                                                 </div>");
                                }
                                                
                                $.unblockUI();
                            } 
                            catch (e) {
                                $.unblockUI();
                            }
                        },
                        error : function(xhr, textStatus, errorThrown) {
                            $.unblockUI();
                        }
                    });
                } catch (e) {
                    alert(e);
                }                 
            }
            
            function checkGeo() {
                        
                var centerLat = map.getCenter().lat();
                var centerLng = map.getCenter().lng();
            
                var cityName = $("#cityName").val();
                
                var selectedTypes = new Array();
                var selectedFurnishing = new Array();
                var selectedPlaces = new Array();
                var selectedStatus = new Array();
                var selectedAmenities = new Array();
                
                $.each($("input[name='typecbx']:checked"), function() {
                    selectedTypes.push($(this).val());
                });                
                $.each($("input[name='furnishcbx']:checked"), function() {
                    selectedFurnishing.push($(this).val());
                });
                $.each($("input[name='placecbx']:checked"), function() {
                    selectedPlaces.push($(this).val());
                });
                $.each($("input[name='statuscbx']:checked"), function() {
                    selectedStatus.push($(this).val());
                });
                $.each($("input[name='amenitycbx']:checked"), function() {
                    selectedAmenities.push($(this).val());
                });
                 
                var longMonthRateLow = $( "#longMonthRateLow" ).val();
                var longMonthRateHigh = $( "#longMonthRateHigh" ).val();
                
                var sqAreaLow = $( "#sqAreaLow" ).val();
                var sqAreaHigh = $( "#sqAreaHigh" ).val();
                
                var numBedroomsLow = $( "#numBedroomsLow" ).val();
                var numBedroomsHigh = $( "#numBedroomsHigh" ).val();
                
                var numBathroomsLow = $( "#numBathroomsLow" ).val();
                var numBathroomsHigh = $( "#numBathroomsHigh" ).val();
                        
                var itemsPerPage = $("#text-items-per-page").val();
                var pageNumber = $("#text-page-number").val();
                    
                searchGeo(centerLat, centerLng, cityName, longMonthRateLow, longMonthRateHigh, sqAreaLow, sqAreaHigh, numBedroomsLow, numBedroomsHigh, numBathroomsLow, numBathroomsHigh, selectedTypes, selectedFurnishing, selectedPlaces, selectedStatus, selectedAmenities, itemsPerPage, pageNumber);
                
            }
            
            function searchGeo(centerLat, centerLng, cityName, longMonthRateLow, longMonthRateHigh, sqAreaLow, sqAreaHigh, numBedroomsLow, numBedroomsHigh, numBathroomsLow, numBathroomsHigh, selectedTypes, selectedFurnishing, selectedPlaces, selectedStatus, selectedAmenities, itemsPerPage, pageNumber) {
                
                try {
                    if (markers != null && markers.length <= 0 && currentView == 3) {
                        $.blockUI({ message: "<div style='font-family: avant, Century Gothic, Calibri, Verdana; padding: 10px;'>Loading Properties ...</div>" });                
                    }        
                    $.ajax({
                        type: 'POST',
                        url: "${model.props.appPath}/ws/search.htm",
                        data: {
                            a: 2,
                            leaseTermType: 1,
                            cityName: cityName,
                            propertyTypeIDs: "["+selectedTypes+"]",
                            furnishTypeIDs: "["+selectedFurnishing+"]",
                            placeIDs: "["+selectedPlaces+"]",
                            statusTypeIDs: "["+selectedStatus+"]",
                            amenityIDs: "["+selectedAmenities+"]",
                            sqAreaLow: sqAreaLow,
                            sqAreaHigh: sqAreaHigh,
                            longMonthRateLow: longMonthRateLow,
                            longMonthRateHigh: longMonthRateHigh,
                            numBedroomsLow: numBedroomsLow,
                            numBedroomsHigh: numBedroomsHigh,
                            numBathroomsLow: numBathroomsLow,
                            numBathroomsHigh: numBathroomsHigh,
                            itemsPerPage: itemsPerPage,
                            pageNumber: pageNumber,
                            ham: "ham",
                            centerLat: centerLat,
                            centerLng: centerLng
                        },
                        timeout : 200000,
                        success: function(data) {
                            $.unblockUI();
                            try {                                
                                var searchResult = data.model.searchResult;                                    
                                var placeMarkers = searchResult.placeMarkers;                  
                                var totalListings = searchResult.totalListings; 
                                
                                //CX: display total count
                                //$("#span-listings-count").html(totalListings); 
                                
                                //CX: reflect map view
                                clearMapViewMarkers();                                                                     
                                for (var i = 0; i < placeMarkers.length; i++) {
                                    putPlaceMarker(placeMarkers[i]);
                                }      
                            } 
                            catch (e) {
                                alert("Search Geo Error: " + e);
                            }
                        },
                        error : function(xhr, textStatus, errorThrown) {
                            //alert('WS Error: ' + xhr);
                            //alert('WS Error: ' + textStatus);
                            //alert('WS Error: ' + errorThrown);
                            $.unblockUI();
                        }
                    });
                } catch (e) {
                    $.unblockUI();
                    alert(e);
                }   
            }
                 
            //CX: used by google map baloon popup
            function checkGeoPlace(placeID) {
                
                var selectedTypes = new Array();
                var selectedFurnishing = new Array();
                var selectedPlaces = new Array();
                var selectedStatus = new Array();
                var selectedAmenities = new Array();
                
                //CX: add place
                selectedPlaces.push(placeID);
                
                $.each($("input[name='typecbx']:checked"), function() {
                    selectedTypes.push($(this).val());
                });                
                $.each($("input[name='furnishcbx']:checked"), function() {
                    selectedFurnishing.push($(this).val());
                });
                $.each($("input[name='placecbx']:checked"), function() {
                    selectedPlaces.push($(this).val());
                });
                $.each($("input[name='statuscbx']:checked"), function() {
                    selectedStatus.push($(this).val());
                });
                $.each($("input[name='amenitycbx']:checked"), function() {
                    selectedAmenities.push($(this).val());
                });
                                
                var longMonthRateLow = $( "#longMonthRateLow" ).val();
                var longMonthRateHigh = $( "#longMonthRateHigh" ).val();
                
                var sqAreaLow = $( "#sqAreaLow" ).val();
                var sqAreaHigh = $( "#sqAreaHigh" ).val();
                
                var numBedroomsLow = $( "#numBedroomsLow" ).val();
                var numBedroomsHigh = $( "#numBedroomsHigh" ).val();
                
                var numBathroomsLow = $( "#numBathroomsLow" ).val();
                var numBathroomsHigh = $( "#numBathroomsHigh" ).val();
                        
                var itemsPerPage = $("#text-items-per-page").val();
                var pageNumber = $("#text-page-number").val();
                    
                searchGeoPlace(placeID, longMonthRateLow, longMonthRateHigh, sqAreaLow, sqAreaHigh, numBedroomsLow, numBedroomsHigh, numBathroomsLow, numBathroomsHigh, selectedTypes, selectedFurnishing, selectedPlaces, selectedStatus, selectedAmenities, itemsPerPage, pageNumber);
            }
            
            function searchGeoPlace(placeID, longMonthRateLow, longMonthRateHigh, sqAreaLow, sqAreaHigh, numBedroomsLow, numBedroomsHigh, numBathroomsLow, numBathroomsHigh, selectedTypes, selectedFurnishing, selectedPlaces, selectedStatus, selectedAmenities, itemsPerPage, pageNumber) {
                
                try {
                    $.ajax({
                        type: 'POST',
                        url: "${model.props.appPath}/ws/search.htm",
                        data: {
                            a: 3,
                            leaseTermType: 1,
                            propertyTypeIDs: "["+selectedTypes+"]",
                            furnishTypeIDs: "["+selectedFurnishing+"]",
                            placeIDs: "["+selectedPlaces+"]",
                            statusTypeIDs: "["+selectedStatus+"]",
                            amenityIDs: "["+selectedAmenities+"]",
                            sqAreaLow: sqAreaLow,
                            sqAreaHigh: sqAreaHigh,
                            longMonthRateLow: longMonthRateLow,
                            longMonthRateHigh: longMonthRateHigh,
                            numBedroomsLow: numBedroomsLow,
                            numBedroomsHigh: numBedroomsHigh,
                            numBathroomsLow: numBathroomsLow,
                            numBathroomsHigh: numBathroomsHigh,
                            itemsPerPage: itemsPerPage,
                            pageNumber: pageNumber,
                            ham: "ham"
                        },
                        timeout : 200000,
                        success: function(data) {
                            try {                                
                                var searchResult = data.model.searchResult;                       
                                var listings = searchResult.listings;  
                                var listingsString = "";
                                var listingsInner = "";
                                
                                for (var i = 0; i < listings.length; i++) {
                                    var longMonthRate = listings[i].longMonthRate;
                                    var numBedrooms = listings[i].numBedrooms;
                                    var sqArea = listings[i].sqArea;

                                    var bedDisplay = "";
                                    if (numBedrooms == 0) {
                                        bedDisplay = "Studio";
                                    }
                                    else {
                                        bedDisplay = numBedrooms + " bedroom";
                                    }

                                    var contentDisplay = "";
                                    if (!listings[i].available) {                                        
                                        contentDisplay = "<strike title=' Unit is rented out. '>&nbsp; &#8369; "+longMonthRate+"/Mo.  &bull;  "+bedDisplay+"  &bull;  "+sqArea+" Sqm.</strike>";
                                    }
                                    else {
                                        contentDisplay = "&nbsp; &#8369; "+longMonthRate+"/Mo.  &bull;  "+bedDisplay+"  &bull;  "+sqArea+" Sqm.";
                                    }

                                    var prmaryPhoto="";
                                    if (listings[i].primaryPhoto) {
                                        prmaryPhoto = listings[i].primaryPhoto.filename;
                                    }
                                    
                                    var titleDisplay = listings[i].title;
                                    if (!listings[i].available) {
                                        titleDisplay = "<strike>"+listings[i].title+"</strike>"
                                    }
                                    var listingTitle = listings[i].urlTitle;
                                                                        
                                    listingsInner += "<tr style=''>\n\
                                       <td style='padding:0px; height: 60px; background-color: #eee;'><a href='${model.props.appPath}/long-term-rentals/${fn:toLowerCase(model.city.title)}/"+listingTitle+"/"+listings[i].id+"' target='_blank'><img style='height: 60px;' src='${model.props.rootPath}/uploads/img/002-"+prmaryPhoto+"'/></a></td>\n\
                                       <td><a href='${model.props.appPath}/long-term-rentals/${fn:toLowerCase(model.city.title)}/"+listingTitle+"/"+listings[i].id+"' target='_blank' style='font-family: avant, Century Gothic, Calibri; font-size: 15px; font-weight: normal;'>"+contentDisplay+"</a></td>\n\
                                     </tr>";
                                }
                                listingsString = "<table>" + listingsInner + "</table>";
                                
                                $("#placeListings-"+placeID).html(listingsString);
                            } 
                            catch (e) {
                                //alert("Search Geo Error: " + e);
                            }
                        },
                        error : function(xhr, textStatus, errorThrown) {
                            //alert('WS Error: ' + xhr);
                            //alert('WS Error: ' + textStatus);
                            //alert('WS Error: ' + errorThrown);
                        }
                    });
                } catch (e) {
                    alert(e);
                }   
            }
                          
            function switchView(view) {
                currentView = view;
                if (view == 1) {
                    $("#view-tiles").css("display", "block");
                    $("#view-list").css("display", "none");
                    $("#view-map").css("display", "none");
                    
                    check();
                    
                    $("#map-wrapper").css("display", "block");
                    $("#btn-page-next").css("visibility", "visible");
                    $("#btn-page-prev").css("visibility", "visible");
                    $("#map_canvas").css("display", "block");
                    $("#span-listings-count-holder").css("display", "block");
                }
                else if (view == 2) {
                    $("#view-tiles").css("display", "none");
                    $("#view-list").css("display", "block");
                    $("#view-map").css("display", "none");
                    
                    check();
                    
                    $("#map-wrapper").css("display", "block");
                    $("#btn-page-next").css("visibility", "visible");
                    $("#btn-page-prev").css("visibility", "visible");
                    $("#map_canvas").css("display", "block");
                    $("#span-listings-count-holder").css("display", "block");
                }
                else if (view == 3) {
                    $("#view-tiles").css("display", "none");
                    $("#view-list").css("display", "none");
                    $("#view-map").css("display", "block");
                    
                    try { markers = []; } catch (e) { }
                    initMapView('${model.city.lat}', '${model.city.lng}');
                    checkGeo();
                    
                    $("#map-wrapper").css("display", "none");
                    $("#btn-page-next").css("visibility", "hidden");
                    $("#btn-page-prev").css("visibility", "hidden");
                    $("#map_canvas").css("display", "none");
                    $("#span-listings-count-holder").css("display", "none");
                }
            }
        </script>
        
        
        
    </head>
    
    <body onload="load();" style="text-align: center; background-color: #FAFAFA; color: #404042; font-family: avant, Century Gothic, Calibri, Verdana; padding: 0px; margin: 0px;" >
                
        <div style="display:inline-block; margin-top: 0px; background-color: white; width: 100%">
                        
            <%@include file="header.jsp" %>
            
            <div style="width: 100%; height: 100%; text-align: left; font-family: avant, Tahoma; color: #404042; background-color: white; background: url('${model.props.appPath}/img/content-bg-short.jpg'); background-repeat: repeat-x; display: block; position: relative; top: -2px;">
                      
                <table border="0" style="width: 100%; height: 100%; border-collapse: collapse;" >
                    <tr>
                        
                        <td id="sidepanel" style="width: 252px; vertical-align: top; border-right: 1px solid #f5f5f5;"> 
                            
                            <c:if test="${model.view == 3}">
                            <div id="map-wrapper" style="position: relative; display: none;">
                            </c:if>
                            <c:if test="${model.view != 3}">
                            <div id="map-wrapper" style="position: relative; display: block;">                                
                            </c:if>
                                <div id="map_canvas" style="width:270px; height:230px;"></div>   
                                <div id="over_map" style=" position: absolute; top:5px; left: 147px; z-index: 99;"> 
                                    <input type="button" value=" Show larger map " style="padding: 3px;" onclick="switchView(3)"/>
                                </div>
                            </div>
                                                            
                            <div style="background: url('${model.props.appPath}/img/sidebar-separator.jpg'); height: 34px; font-weight: bold; font-size: 14px;">                                
                                <div style="padding-top: 7px;">&nbsp;&nbsp; Property Type</div>
                            </div>   
                            
                            <div style="font-size: 14px; padding: 5px; margin-left: 10px;  margin-top:5px;  margin-bottom:5px; font-family: avant, Century Gothic, Verdana;">                                
                                <table>          
                                    <tr>
                                        <td><input id="checkbox-propertyType-2" type="checkbox" name="typecbx" value="2,3" /></td>
                                        <td>Condo / Apartment</td>
                                    </tr>
                                    <tr>
                                        <td><input id="checkbox-propertyType-1" type="checkbox" name="typecbx" value="1" /></td>
                                        <td>House</td>
                                    </tr>                                    
                                    <tr>
                                        <td><input id="checkbox-propertyType-4" type="checkbox" name="typecbx" value="4" /></td>
                                        <td>Townhouse</td>
                                    </tr>  
                                    <tr>
                                        <td><input id="checkbox-propertyType-5" type="checkbox" name="typecbx" value="5" /></td>
                                        <td>Room</td>
                                    </tr>
                                </table> 
                            </div> 
                                     
                            <div style="background: url('${model.props.appPath}/img/sidebar-separator.jpg'); height: 34px; font-weight: bold; font-size: 14px;">                                
                                <div style="padding-top: 7px;">&nbsp;&nbsp; Furnishing</div>
                            </div>   
                            
                            <div style="font-size: 14px; padding: 5px; margin-left: 10px;  margin-top:5px;  margin-bottom:5px; font-family: avant, Century Gothic, Verdana;">                                
                                <table>        
                                    <tr>
                                        <td><input id="checkbox-furnishType-3" type="checkbox" name="furnishcbx" value="3" /></td>
                                        <td>Fully Furnished</td>
                                    </tr>  
                                    <tr>
                                        <td><input id="checkbox-furnishType-2" type="checkbox" name="furnishcbx" value="2" /></td>
                                        <td>Semi Furnished</td>
                                    </tr>
                                    <tr>
                                        <td><input id="checkbox-furnishType-1" type="checkbox" name="furnishcbx" value="1" /></td>
                                        <td>Unfurnished</td>
                                    </tr>
                                </table> 
                            </div> 
                            
                            <div style="background: url('${model.props.appPath}/img/sidebar-separator.jpg'); height: 34px; font-weight: bold; font-size: 14px;">                                
                                <div style="padding-top: 7px;">&nbsp;&nbsp; Monthly Rate </div>
                            </div>                            
                            
                            <div style="font-size: 14px; padding: 5px; margin-left: 0px; margin-top:5px;">                                
                                
                                <input id="longMonthRateLow" type="hidden" name="longMonthRateLow" style="width:80px" value="0" />   
                                <input id="longMonthRateHigh" type="hidden" name="longMonthRateHigh" style="width:80px" value="999999" />
                                                                
                                <table border="0" cellspacing="5" cellpadding="5">
                                    <tr>
                                        <td>
                                            <select id="select-longMonthRateLow" style="padding: 3px; width: 90px;">
                                                <option value="0" selected>Min</option>
                                                <option value="1,000">&#8369; 1,000</option>
                                                <option value="5,000">&#8369; 5,000</option>
                                                <option value="10,000">&#8369; 10,000</option>
                                                <option value="20,000">&#8369; 20,000</option>
                                                <option value="30,000">&#8369; 30,000</option>
                                                <option value="40,000">&#8369; 40,000</option>
                                                <option value="50,000">&#8369; 50,000</option>
                                                <option value="60,000">&#8369; 60,000</option>
                                                <option value="70,000">&#8369; 70,000</option>
                                                <option value="80,000">&#8369; 80,000</option>
                                                <option value="90,000">&#8369; 90,000</option>
                                                <option value="100,000">&#8369; 100,000</option>
                                                <option value="150,000">&#8369; 150,000</option>
                                                <option value="200,000">&#8369; 200,000</option>
                                                <option value="300,000">&#8369; 300,000</option>
                                                <option value="999999" >Max</option>
                                            </select>                                           
                                        </td>
                                        <td>
                                            To                                            
                                        </td>
                                        <td>
                                            <select id="select-longMonthRateHigh" style="padding: 3px; width: 90px;">
                                                <option value="0">Min</option>
                                                <option value="1,000">&#8369; 1,000</option>
                                                <option value="5,000">&#8369; 5,000</option>
                                                <option value="10,000">&#8369; 10,000</option>
                                                <option value="20,000">&#8369; 20,000</option>
                                                <option value="30,000">&#8369; 30,000</option>
                                                <option value="40,000">&#8369; 40,000</option>
                                                <option value="50,000">&#8369; 50,000</option>
                                                <option value="60,000">&#8369; 60,000</option>
                                                <option value="70,000">&#8369; 70,000</option>
                                                <option value="80,000">&#8369; 80,000</option>
                                                <option value="90,000">&#8369; 90,000</option>
                                                <option value="100,000">&#8369; 100,000</option>
                                                <option value="150,000">&#8369; 150,000</option>
                                                <option value="200,000">&#8369; 200,000</option>
                                                <option value="300,000">&#8369; 300,000</option>
                                                <option value="999999" selected>Max</option>
                                            </select>  
                                        </td>
                                    </tr>
                                </table>
                                
                            </div> 
                                                   
                            <div style="background: url('${model.props.appPath}/img/sidebar-separator.jpg'); height: 34px; font-weight: bold; font-size: 14px;">                                
                                <div style="padding-top: 7px;">&nbsp;&nbsp; Bedrooms</div>
                            </div>
                                
                            <div style="font-size: 14px; padding: 5px; margin-left: 0px; margin-top:5px;">     
                                    
                                <input id="numBedroomsLow" type="hidden" name="numBedroomsLow" style="width:80px" value="0" />   
                                <input id="numBedroomsHigh" type="hidden" name="numBedroomsHigh" style="width:80px" value="999" />
                                                                
                                <table border="0" cellspacing="5" cellpadding="5">
                                    <tr>
                                        <td>
                                            <select id="select-numBedroomsLow" style="padding: 3px; width: 90px;">
                                                <option value="0" selected>Min</option>
                                                <option value="0">0</option>
                                                <option value="1">1</option>
                                                <option value="2">2</option>
                                                <option value="3">3</option>
                                                <option value="4">4</option>
                                                <option value="999">Max</option>
                                            </select>                                           
                                        </td>
                                        <td>
                                            To                                            
                                        </td>
                                        <td>
                                            <select id="select-numBedroomsHigh" style="padding: 3px; width: 90px;">
                                                <option value="0">Min</option>
                                                <option value="0">0</option>
                                                <option value="1">1</option>
                                                <option value="2">2</option>
                                                <option value="3">3</option>
                                                <option value="4">4</option>
                                                <option value="999" selected>Max</option>
                                            </select>  
                                        </td>
                                    </tr>
                                </table>
                                                                
                                <div style="height: 20px; font-weight: bold; font-size: 14px; margin-top: 10px; border-top: 1px dashed #cacaca;">                                
                                    <div style="padding-top: 2px;">&nbsp;&nbsp; </div>
                                </div>
                                
                                <table border="0" cellspacing="5" cellpadding="5">
                                    <tr>
                                        <td><a href="#" class="btn-search" onclick="doSearch()">Search</a></td>
                                    </tr>
                                </table>
                                
                                <style>
                                    .btn-search {
                                            background-color:#5cbf2a;
                                            -moz-border-radius:7px;
                                            -webkit-border-radius:7px;
                                            border-radius:7px;
                                            border:1px solid #5cbf2a;
                                            display:inline-block;
                                            cursor:pointer;
                                            color:#ffffff;
                                            font-family:arial;
                                            font-size:18px;
                                            padding:8px 95px;
                                            text-decoration:none;
                                            text-shadow:0px 1px 0px #5cbf2a;
                                    }
                                    .btn-search:hover {
                                            background-color:#5cbf2a;
                                    }
                                    .btn-search:active {
                                            position:relative;
                                            top:1px;
                                    }
                                    .btn-search:visited {
                                            position:relative;
                                            top:1px;
                                            color:#ffffff;
                                    }
                            </style>

                            </div> 
                            
                            
                            <!--
                            <div style="background: url('${model.props.appPath}/img/sidebar-separator.jpg'); height: 34px; font-weight: bold; font-size: 14px;">                                
                                <div style="padding-top: 7px;">&nbsp;&nbsp; Square Area</div>
                            </div>
                                
                            <div style="font-size: 14px; padding: 5px; margin-left: 0px; margin-top:5px;">  
                                    
                                <input id="sqAreaLow" type="hidden" name="sqAreaLow" style="width:80px" value="0" />   
                                <input id="sqAreaHigh" type="hidden" name="sqAreaHigh" style="width:80px" value="999999" />
                                         
                                <table border="0" cellspacing="5" cellpadding="5">
                                    <tr>
                                        <td>
                                            <select id="select-sqAreaLow" style="padding: 3px; width: 90px;">
                                                <option value="0" selected>Min</option>
                                                <option value="10">10 sqm.</option>
                                                <option value="20">20 sqm.</option>
                                                <option value="30">30 sqm.</option>
                                                <option value="40">40 sqm.</option>
                                                <option value="50">50 sqm.</option>
                                                <option value="70">70 sqm.</option>
                                                <option value="90">90 sqm.</option>
                                                <option value="100">100 sqm.</option>
                                                <option value="120">120 sqm.</option>
                                                <option value="150">150 sqm.</option>
                                                <option value="180">180 sqm.</option>
                                                <option value="200">200 sqm.</option>
                                                <option value="999999">Max</option>
                                            </select>                                           
                                        </td>
                                        <td>
                                            To                                            
                                        </td>
                                        <td>
                                            <select id="select-sqAreaHigh" style="padding: 3px; width: 90px;">
                                                <option value="0" selected>Min</option>
                                                <option value="10">10 sqm.</option>
                                                <option value="20">20 sqm.</option>
                                                <option value="30">30 sqm.</option>
                                                <option value="40">40 sqm.</option>
                                                <option value="50">50 sqm.</option>
                                                <option value="70">70 sqm.</option>
                                                <option value="90">90 sqm.</option>
                                                <option value="100">100 sqm.</option>
                                                <option value="120">120 sqm.</option>
                                                <option value="150">150 sqm.</option>
                                                <option value="180">180 sqm.</option>
                                                <option value="200">200 sqm.</option>
                                                <option value="999999">Max</option>
                                            </select>  
                                        </td>
                                    </tr>
                                </table>
                                
                            </div> 
                            -->    
                            <br><br><br><br>
                                
                        </td>
                        
                        <td style="vertical-align: top;">    
                            
                            <div id="toolbar" style="padding-top: 5px; padding-bottom: 0px;"> 
                                
                                <table style="width: 95%; margin-left: 20px; font-family: avant, Century Gothic, Verdana">
                                    <tr>
                                        <td>
                                            <span id="span-listings-count-holder">
                                                <span id="span-listings-count" style="font-weight: bold; font-size: 20px;">                                                
                                                    <c:if test="${model.searchResult.totalListings <= 0}">
                                                        There are no
                                                    </c:if>
                                                    <c:if test="${model.searchResult.totalListings > 0}">
                                                        ${model.searchResult.totalListings}
                                                    </c:if>
                                                </span>   
                                                long term rentals in 
                                                <span id="span-listings-count" style="font-weight: bold; font-size: 20px;;">${model.city.title}</span>     
                                            </span>
                                            
                                            <input id="cityName" type="hidden" value="${model.city.title}"/>
                                            <c:if test="${model.searchResult.totalListings <= 0}">
                                                &nbsp;&nbsp;&nbsp;<a href="${model.props.appPath}/home.htm" style="color:#369; font-size: 13px; text-decoration: underline;">Search for a rental property</a>
                                            </c:if>
                                        </td>
                                        <td align="right">
                                            <img src="${model.props.appPath}/img/view-tiles-button.png" onclick="switchView(1)" style="cursor: pointer; height: 35px;"/>
                                            &nbsp;
                                            <img src="${model.props.appPath}/img/view-list-button.png" onclick="switchView(2)" style="cursor: pointer; height: 35px;"/>
                                            &nbsp;
                                            <img src="${model.props.appPath}/img/view-map-button.png" onclick="switchView(3)" style="cursor: pointer; height: 35px;"/>
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        </td>
                                    </tr>
                                </table>         
                            </div>    
                                            
                                          
                                            
                                            
                            <c:if test="${model.view != 3}">
                            <div id="view-tiles" style="display:block; margin-top: -15px">         
                            </c:if>
                            <c:if test="${model.view == 3}">
                            <div id="view-tiles" style="display:none; margin-top: -15px">         
                            </c:if>
                                                                
                                <div class="view-tile-outer">
                                    <div id="view-tile-float-wrap" class="view-tile-float-wrap">   
                                        
                                        
                                        <c:forEach items="${model.featureds}" var="listing">   
                                            
                                            <div class="view-tile-left-floater listing-holder" style="min-height: 230px; width: 297px; border: 3px solid rgba(131,201,12,0.5); position: relative; left:-2px;">
                                                
                                                <a href="${model.props.appPath}/long-term-rentals/${fn:toLowerCase(model.city.title)}/${fn:replace(listing.displayTitle, ' ', '-')}/${listing.id}" title="Featured Property &#10004;">                                                    
                                                    <c:choose>
                                                        <c:when test="${not empty listing.primaryPhoto.filename}">
                                                            <div class="listing-photo-holder" style="height:147px; width:297px; background: url('${model.props.rootPath}/uploads/img/002-${listing.primaryPhoto.filename}'); background-size:cover;">
                                                                <img src="${model.props.rootPath}/uploads/img/002-${listing.primaryPhoto.filename}" style="display:none;" alt="${listing.title}"/>
                                                            </div>
                                                        </c:when>
                                                        <c:otherwise>                                                        
                                                            <div class="listing-photo-holder" style="height:147px; width:297px; background: url('${model.props.appPath}/img/no-photo.png'); background-size:cover;">
                                                                <img src="${model.props.appPath}/img/no-photo.png" style="display:none;" alt="${listing.title}" />
                                                            </div>
                                                        </c:otherwise>
                                                    </c:choose>
                                                </a>
                                                
                                                <table border="0" style="width: 300px; padding-top:0px; font-family: avant, Century Gothic, Calibri; padding:5px; ">
                                                    <tr>
                                                        <td colspan="2" style="height: 33px; vertical-align: top; ">
                                                            <div style="min-height: 30px; max-height: 30px; font-size: 13px; font-weight: normal; overflow: hidden; overflow-y: hidden; border: 0px solid black; font-family: avant, Century Gothic, Calibri;">
                                                                <c:if test="${listing.available}">
                                                                    <span >${listing.title}</span>
                                                                </c:if>
                                                                <c:if test="${!listing.available}">
                                                                    <span ><strike title=" Unit is rented out. ">${listing.title}</strike></span>
                                                                </c:if>
                                                                <br>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td width="106px">                                                            
                                                            <c:if test = "${listing.sqArea != '0.0'}">
                                                                <span style="font-size: 13px;">&nbsp;${listing.sqArea}</span><span style="font-size: 12px;"> sqm.</span>
                                                            </c:if>
                                                        </td>
                                                        <td align="right" style="font-weight: bold;">                                        
                                                            <span style="font-size: 13px; font-weight: bold;">&#8369; ${listing.longMonthRate}</span>
                                                            <span style="font-size: 12px;"> /mo.&nbsp;</span>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>   
                                        </c:forEach>
                                        
                                        <c:forEach items="${model.listings}" var="listing">   
                                            
                                            <div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="view-tile-left-floater listing-holder" >
                                                
                                                <a href="${model.props.appPath}/long-term-rentals/${fn:toLowerCase(model.city.title)}/${fn:replace(listing.displayTitle, ' ', '-')}/${listing.id}" itemprop="url" title="${listing.title} For Rent in ${model.city.title}">                                                    
                                                    <c:choose>
                                                        <c:when test="${not empty listing.primaryPhoto.filename}">
                                                            <div class="listing-photo-holder" style="height:150px; width:300px; background: url('${model.props.rootPath}/uploads/img/002-${listing.primaryPhoto.filename}'); background-size:cover;">
                                                                <img itemprop="image" src="${model.props.rootPath}/uploads/img/002-${listing.primaryPhoto.filename}" style="display:none;" alt="${listing.title}" />
                                                            </div>
                                                        </c:when>
                                                        <c:otherwise>                                                        
                                                            <div class="listing-photo-holder" style="height:150px; width:300px; background: url('${model.props.appPath}/img/no-photo.png'); background-size:cover;">
                                                                <img itemprop="image" src="${model.props.appPath}/img/no-photo.png" style="display:none;" alt="${listing.title}" />
                                                            </div>
                                                        </c:otherwise>
                                                    </c:choose>
                                                </a>
                                                
                                                <table border="0" style="width: 300px; padding-top:0px; font-family: avant, Century Gothic, Calibri; padding:5px; ">
                                                    <tr>
                                                        <td colspan="2" style="height: 33px; vertical-align: top; ">
                                                            <div itemprop="itemOffered" itemscope itemtype="http://schema.org/Product" style="min-height: 30px; max-height: 30px; font-size: 13px; font-weight: normal; overflow: hidden; overflow-y: hidden; border: 0px solid black; font-family: avant, Century Gothic, Calibri;">
                                                                <c:if test="${listing.available}">
                                                                    <span itemprop="name">${listing.title}</span>
                                                                </c:if>
                                                                <c:if test="${!listing.available}">
                                                                    <span itemprop="name"><strike title=" Unit is rented out. ">${listing.title}</strike></span>
                                                                </c:if>
                                                                <br>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td width="106px">                                                            
                                                            <c:if test = "${listing.sqArea != '0.0'}">
                                                                <span style="font-size: 13px;">&nbsp;${listing.sqArea}</span><span style="font-size: 12px;"> sqm.</span>
                                                            </c:if>
                                                        </td>
                                                        <td align="right" style="font-weight: bold;">
                                                            <meta itemprop="priceCurrency" content="PHP" />                                                            
                                                            <span itemprop="price" style="font-size: 13px; font-weight: bold;">&#8369; ${listing.longMonthRate}</span>
                                                            <span style="font-size: 12px;"> /mo.&nbsp;</span>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>   
                                        </c:forEach>
                                        
                                    </div>
                                </div>​
                                <br><br>
                            </div>
                                                        
                            <div id="view-list" style="display:none;">                         
                                <div id="view-list-outer" class="view-list-outer">      
                                    
                                    <c:forEach items="${model.listings}" var="listing">                                
                                        <div class="list-listing-holder" style="background-color:#f8f8f8; width: 97%; margin-top: 10px; margin-left:10px;">
                                            <table cellpadding="3" style="width:100%; font-family: avant, Century Gothic, Calibri;">
                                                <tr>
                                                    <td style="height: 100px; width: 10%">
                                                        
                                                        <a href="${model.props.appPath}/long-term-rentals/${fn:toLowerCase(model.city.title)}/${fn:replace(listing.displayTitle, ' ', '-')}/${listing.id}" title="${listing.title}">
                                                            <c:choose>
                                                                <c:when test="${not empty listing.primaryPhoto.filename}">
                                                                    <div class="list-listing-holder" style="height:110px; width:200px; background: url('${model.props.rootPath}/uploads/img/002-${listing.primaryPhoto.filename}'); background-size:cover;">

                                                                    </div>
                                                                </c:when>
                                                                <c:otherwise>                                                        
                                                                    <div class="list-listing-holder" style="height:110px; width:200px; background: url('${model.props.appPath}/img/no-photo.png'); background-size:cover;">

                                                                    </div>
                                                                </c:otherwise>
                                                            </c:choose>
                                                            
                                                        </a>  
                                                    </td>
                                                    <td style="vertical-align: top;">
                                                        <table border="0" style="width: 98%; padding-top:15px; margin-left: 0px; font-family: avant, Century Gothic, Calibri;">
                                                            <tr>
                                                                <td style="vertical-align: top;  width: 550px;">
                                                                    <div style="padding-top:5px; padding-bottom:0px;">                                                                    
                                                                        <span style="font-size: 16px; padding-bottom: 10px">
                                                                            <c:if test="${listing.available}">
                                                                                ${listing.title}
                                                                            </c:if>
                                                                            <c:if test="${!listing.available}">
                                                                                <strike title=" Unit is rented out. ">${listing.title}</strike>
                                                                            </c:if>                                       
                                                                        </span>
                                                                    </div>
                                                                    <div style="padding-top:8px; padding-bottom:0px;">
                                                                        <span style="font-size: 14px; font-weight: normal;">${listing.address}</span>
                                                                    </div>
                                                                </td>
                                                                <td  style="vertical-align: top;" align="right">                       
                                                                    
                                                                    <div style="padding-top:0px; padding-bottom:0px; font-weight: bold;">  
                                                                        <span style="font-size: 22px;">&#8369;${listing.longMonthRate}</span>
                                                                        <span style="font-size: 12px;"> /Mo.</span>
                                                                    </div>
                                                                    
                                                                    <div style="padding-top:5px; padding-bottom:0px;">                                                                                                   
                                                                        <c:if test = "${listing.sqArea != '0.0'}">
                                                                            <span style="font-size: 16px; font-weight: normal;">${listing.sqArea}</span>
                                                                            <span style="font-size: 12px;"> sqm.</span>
                                                                        </c:if>
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </c:forEach>
                                    
                                </div>
                                <br><br>
                            </div>
                                                
                            <c:if test="${model.view == 3}">
                            <div id="view-map" style="display:block; margin-left: -12px;">       
                            </c:if>
                            <c:if test="${model.view != 3}">
                            <div id="view-map" style="display:none; margin-left: -12pxm;">       
                            </c:if>              
                                
                                <table style="margin-top:5px; width: 99%;">
                                    <tr>
                                        <td>
                                            <div id="view-map-inner" style="width: 99%; height:600px; margin-left: 15px"></div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                              
                            
                            <table style="text-align: right; width: 100%;"> 
                                <tr>
                                    <td>
                                        <c:choose>                                            
                                            <c:when test="${model.searchResult.hasPrev}">
                                                <input id="btn-page-prev" type="button" value=" Previous Page " onclick="prev()" style="padding:3px; width: 110px;" />
                                            </c:when>
                                            <c:otherwise>
                                                <input id="btn-page-prev" type="button" value=" Previous Page " onclick="prev()" style="padding:3px; width: 110px;" disabled="true"/>
                                            </c:otherwise>
                                        </c:choose>
                                        
                                        &nbsp;&nbsp;
                                        
                                        <c:choose>                                            
                                            <c:when test="${model.searchResult.hasNext}">
                                                <input id="btn-page-next" type="button" value=" Next Page " onclick="next()" style="padding:3px; width: 110px;" />
                                            </c:when>
                                            <c:otherwise>
                                                <input id="btn-page-next" type="button" value=" Next Page " onclick="next()" style="padding:3px; width: 110px;" disabled="true" />
                                            </c:otherwise>
                                        </c:choose>                                   
                                        
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <br><br>

                                        <input id="text-items-per-page" type="hidden" value="12" />
                                        <input id="text-page-number" type="hidden" value="1" />

                                        <br>
                                
                                    </td>
                                </tr>
                            </table>
                                            
                            
                            <div style="width: 90%; background-color: #f7f7f7; margin-left: 20px; display:none;">
                                <br>
                                <table cellpadding="5" cellspacing="5" border="0">
                                    <tr>
                                        <td width="650px;">
                                            <span style="font-size: 19px;">&nbsp;&nbsp;Would to be notified for new properties listed in <b>${model.city.title}</b>?</span>
                                        </td>
                                        <td>
                                            <img src="${model.props.appPath}/img/btn-notify-me-2.png" />
                                        </td>
                                    </tr>
                                </table>
                                <br>
                            </div>    
                            
                            <br>
                            <br>  
                        </td>
                    </tr>
                </table>
                
            </div>
                
            
            <%@include file="footer.jsp" %>
            
            <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>  
        
        </div>
        
            
    </body>
</html>
